/*************************************************************************
    > File Name: hello5.c
    > Author: Xing.Dai
    > Mail: Xing.Dai@aliyun.com 
    > Created Time: 2017-05-24 22:33
 ************************************************************************/

#include <stdio.h>
#include <curses.h>
#include <unistd.h>

#define LEFT_EDGE	10
#define RIGHT_EDGE	30
#define ROW			10

int main()
{
	char *message = "Hello";
	char *blank   = "     ";
	int dir = +1;
	int pos = LEFT_EDGE;

	initscr();
	clear();
	
	for( ; ; ){
		move(ROW, pos);
		addstr(message);
		move(LINES - 1, COLS - 1);
		refresh();

		sleep(1);

		move(ROW, pos);
		addstr(blank);

		pos += dir;

		if(pos >= RIGHT_EDGE)
			dir = -1;
		if(pos <= LEFT_EDGE)
			dir = +1;
	}


	return 0;
}


